package com.contract.utils;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtil {
	
	static {
		
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}	
	}
	
	
	public static Connection getConnection() throws SQLException{
		//期权家
		String url = "jdbc:mysql://rm-bp1505cy03ss6rd70.mysql.rds.aliyuncs.com/app_qqj?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false";		
		//点点期权
		//String url = "jdbc:mysql://127.0.0.1:3306/db_option?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false";	

		String user = "appqqj";
		String password = "mysql2016mob";
		Connection conn = DriverManager.getConnection(url,user,password);
		conn.setAutoCommit(false);
		return conn;
	}
	
	
	
	public static void closeConnection(Connection conn){
		try {	
			if(conn!=null && !conn.isClosed()){
				conn.close();
			}			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	} 
}
